package com.example.demo.filter;

import javax.servlet.*;
import java.io.IOException;

public class RequestBeforeFilter implements Filter {

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException {
        String path = request.getServletContext().getContextPath();
        System.out.println("Request Path: " + path);
        chain.doFilter(request, response);
    }

    @Override
    public void destroy() {
        System.out.println("hello world");
        // 清理资源
    }
}
